package com.hy.mydesktop.shared.business;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.hy.mydesktop.client.component.meta.GridColumnConfigModel;
import com.hy.mydesktop.client.component.mvc.event.EventStructureMetaModel;
import com.hy.mydesktop.client.component.type.ComponentTypeEnum;
import com.hy.mydesktop.client.mvc.core.builder.GridBuilderTemplate;
import com.hy.mydesktop.client.mvc.core.builder.WindowApplicationBuildTemplate;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtAppEventType;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.ItemOfAssociateToWindow;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.ComponentMetaDataConstants;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceParameter;

public class EducationServices {

	

	public GxtComponentControllerMetaModel createDynamicWindowController()
	{
		String controllerMetaModelId="educationServices";		
		Map<String , Object> gridMap2=new HashMap<String, Object>();
		String formId="educationService";
		gridMap2=createGridMap2(controllerMetaModelId,formId, gridMap2);
		
		GxtComponentControllerMetaModel gxtComponentControllerMetaModel=
			WindowApplicationBuildTemplate.createSimpleWindowApplication_model1(
				controllerMetaModelId,"教育设置",formId,gridMap2);

		return gxtComponentControllerMetaModel;		

	}
	
	
	

	private Map<String, Object> createGridMap2(String controllerMetaModelId, String formId, Map<String, Object> gridMap2) {
		Map<String, Object> map2 = new HashMap<String, Object>();
//		map2.put("component_model_type", ComponentTypeEnum.GRIDSETMODULES_MODEL);
		map2.put("component_model_type_index", ComponentTypeEnum.GRIDSETMODULES_MODEL.ordinal());
		map2.put("autowidth", true);
		map2.put("autoheight", true);
		map2.put("frame", true);
		map2.put("headervisible", false);
		map2.put(ComponentMetaDataConstants.GRIDMODULE_TYPE, ComponentTypeEnum.GRIDMODULE_MODEL.toString());
			map2.put("version",4);//可编辑分页表格
			map2.put("headervisible",false );
			map2.put("rownumber", true);
		List<GridColumnConfigModel> columnConfigs = new ArrayList<GridColumnConfigModel>();		
		columnConfigs.add(new GridColumnConfigModel("EDUCATIONNAME","学历名称",100));
		columnConfigs.add(new GridColumnConfigModel("INSTITUTION","所在院校",100));
		columnConfigs.add(new GridColumnConfigModel("SPECIALITY","所学专业",100));
//		columnConfigs.add(new GridColumnConfigModel("positionType","positionType",100));
//		columnConfigs.add(new GridColumnConfigModel(true,false,"positionType","职位类型",100));
//		columnConfigs.add(new GridColumnConfigModel("positionTypeForShow","职位类型3",100));
		columnConfigs.add(new GridColumnConfigModel(true,"STARTDATE","开始日期",100));
		columnConfigs.add(new GridColumnConfigModel(true,"STOPDATE","结束日期",100));
		columnConfigs.add(new GridColumnConfigModel("REMARK","备注",200));										
		//map3.put("columnconfigload", columnConfigs);
		map2.put(ComponentMetaDataConstants.GRID_COLUMNCONFIG_MODELS,columnConfigs);
		
		List<ItemOfAssociateToWindow> childrenItems=new LinkedList<ItemOfAssociateToWindow>();
//		GxtToSeamServiceParameter g1=new GxtToSeamServiceParameter("positionService" , "getAllPosition" );
		GxtToSeamServiceParameter g1=new GxtToSeamServiceParameter(formId , "getPageOfPersistentEntities" );
		g1.setMethodArgumentsType(null);
		ItemOfAssociateToWindow itemOfAssociateToWindow = new ItemOfAssociateToWindow();
		itemOfAssociateToWindow.setGxtToSeamServiceParameter(g1);
		EventStructureMetaModel eventStructureMetaModel = new EventStructureMetaModel();
		// controllerMetaModelId="positionService";
		eventStructureMetaModel.setRootControllerId("windowController_"+controllerMetaModelId);
		eventStructureMetaModel.setControllerId("gridSetModuleController_"+controllerMetaModelId);
		itemOfAssociateToWindow.setEventStructureMetaModel(eventStructureMetaModel);
		itemOfAssociateToWindow.setItemType(ComponentMetaDataConstants.MVC_ITEM_TYPE);
		itemOfAssociateToWindow.setRegisterEventType(new GxtAppEventType("0401"));
	
		childrenItems.add(itemOfAssociateToWindow);
		/**
		 * 表格下拉框
		 */
		/*Map<String, Object> simpleComboBox01 = new HashMap<String, Object>();			
	    simpleComboBox01.put("component_model_type_index", ComponentTypeEnum.SIMPLECOMBOBOX_MODEL.ordinal()); 	    							
//	    simpleComboBox01.put("id", "positon.positionType");
	    simpleComboBox01.put("id", "positionType");
	    ItemOfAssociateToWindow item  = new ItemOfAssociateToWindow(simpleComboBox01);
	    item.setItemType(ComponentMetaDataConstants.COMPONENT_ITEM_TYPE);
//	    GxtToSeamServiceParameter gxtToSeamServiceParameter=new GxtToSeamServiceParameter("positionTypeService" , "getAllPositonType" );
	    GxtToSeamServiceParameter gxtToSeamServiceParameter=new GxtToSeamServiceParameter("positionTypeService" , "getAllPersistentEntities" );
	    gxtToSeamServiceParameter.setMethodArgumentsType(null);
	    item.setGxtToSeamServiceParameter(gxtToSeamServiceParameter);
	    item.setItemType(ComponentMetaDataConstants.COMPONENT_ITEM_TYPE);*/
		String gridColumnId ="positionType";

	    ItemOfAssociateToWindow item   = GridBuilderTemplate.createItemForComboBoxOfGridColumn(gridColumnId);
		
		
		Map<String, Object> simpleComboBox02 = new HashMap<String, Object>();
	    simpleComboBox02.put("component_model_type_index", ComponentTypeEnum.SIMPLECOMBOBOX_MODEL.ordinal());   
//		simpleComboBox02.put("gxttoseamserviceparametermodel", gxtToSeamServiceParameter_comboBox1);
	    HandlerData.data ( simpleComboBox02 , "organisationService" , "getAllOrganisation" );
//	    simpleComboBox02.put("text", "清空");
	    simpleComboBox02.put("id", "positon.organisation");
	    ItemOfAssociateToWindow node33  = new ItemOfAssociateToWindow(simpleComboBox02);
		
		//表格下拉框代码结束
		
		childrenItems.add(item);
		
		
		//gridMap2.put(ComponentMetaDataConstants.CHILDREN_ITEMS,  childrenItems) ;
		map2.put(ComponentMetaDataConstants.CHILDREN_ITEMS,  childrenItems) ;

		//node2.setChildrenItems(childrenItems);
		return map2;
	}
	
}
